package com.store.pet.petstore.adapter;

import android.graphics.Color;
import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.squareup.picasso.Picasso;
import com.store.pet.petstore.R;
import com.store.pet.petstore.bean.PetListBean;

import java.util.List;

public class PetAdapter extends BaseQuickAdapter<PetListBean.ContentBean.PetlistBean,BaseViewHolder> {

    public PetAdapter(int layoutResId, @Nullable List<PetListBean.ContentBean.PetlistBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, PetListBean.ContentBean.PetlistBean item) {
        helper.setText(R.id.pet_item_name,item.getName());
        helper.setText(R.id.pet_item_price,"价格："+item.getPrice());
        helper.setTextColor(R.id.pet_item_price,Color.GREEN);
        helper.setText(R.id.pet_item_seller,"卖家："+item.getSellername());
        helper.setText(R.id.pet_item_time,"上架时间："+item.getCtime().replaceAll("T"," "));
        ImageView imageView = helper.getView(R.id.pet_item_img);
        Picasso.with(mContext).load(item.getImg()).into(imageView);
        helper.addOnClickListener(R.id.pet_item);
    }
}
